const { fetch } = require('../../utils/util.js')
const WxParse = require('../../wxParse/wxParse.js');
const app = getApp()
Page({
  data: {
    slides: [],
    data: {},
    navigationData:{}
  },
  onLoad: function (options) {
    const _this = this;
    // banner
    fetch({
      url: 'api/zhuang/GetBannerList',
      params: {},
      success: (res) => {
        _this.setData({
          slides: res
        })
      }
    })

    fetch({
      url: 'api/zhuang/GetGonDiInfor',
      params: { id: parseInt(options.id) },
      success: (res) => {
        console.log('工地详情：')
        console.log(res)
        WxParse.wxParse('content', 'html', res.content, _this, 5);
        wx.setNavigationBarTitle({ title: res.title })
        _this.setData({
          data: res,
          navigationData:{
            latitude: res.lat,
            longitude: res.lng,
            scale: 18,
            name: res.sitename,
            address: res.address,
          }
        })
      }
    })
  },
  tabpage: function (e) {
    app.redirectTo(e.currentTarget.dataset.url)
  },
  navigation: function () {
    const {data}=this.data
    wx.openLocation({
      latitude: Number(data.lat),
      longitude: Number(data.lng),
      scale: 14,
      name: data.sitename,
      address: data.address,
    })
  }
})